Skip to content

feat: RBS size reduction#3382

Merged
sichanyoo merged 6 commits into
version-3from
feat/rbs-size-reduction
May 19, 2026
Merged

feat: RBS size reduction#3382
sichanyoo merged 6 commits into
version-3from
feat/rbs-size-reduction

Conversation

@sichanyoo
Copy link
Copy Markdown
Contributor

@sichanyoo sichanyoo commented May 13, 2026

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Changes & Impact

  • Reduces size of aws-sdk-<service>/sig/ folder in generated service gems by factoring out repeatedly used nested input struct definitions into sig/params.rbs as typealiases that get reused in sig/client.rbs.
    • The type definitions already defined under sig/types.rbs cannot be reused because that would make methods no longer accept hash literals.
  • The biggest beneficiary of this change is aws-sdk-quicksight. Its sig/ folder at the time of this PR (aws-sdk-quicksight v1.179.0) was 35.5MB, but after this refactor it's reduced to 0.925MB, which is a reduction of about 97.3%. With other big services like EC2 and S3, reduction is much less due to those services primarily using flat input shape structure. EC2 gets about 5% reduction to its sig/ (3.34MB => 3.17MB) and S3 gets about 1.5% reduction to its sig/ (445KB => 439KB).
  • With this change, method auto-complete suggestions for QuickSight methods actually render instead of being shortened as ... in RubyMine.
  • Gem build time doesn't seem to be impacted based on local, brief manual testing for QuickSight (running build commands and not seeing even a tick of difference AFAICT).
  • InputTypeAliasCollector walks through shapes, caching names of shapes within operation input shapes that appear more than once & would end up taking more than 5 lines in rendered RBS if it were to be generated fully without typealias. It then returns topologically sorted shapes so that leaf shapes (shapes without dependencies) can get rendered first in RBS, allowing latter shapes to simply refer to leaf shapes in their own definitions.
    • Because current changes determine a shape needs aliasing based on how long it would be if it was fully expanded, there is a possibility of unnecessary typealias generation in a special case where a large shape actually becomes 1~2 lines long after child typealias substitutions so it doesn't need to be aliased. But customers would need to refer to params.rbs to look at child typealias definitions anyways & couple extra type alises don't hurt, so additional complexity isn't worth it.

@sichanyoo sichanyoo requested a review from a team as a code owner May 13, 2026 20:51
Copy link
Copy Markdown
Contributor

@jterapin jterapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great so far. I'm curious to see the overall size reduction. Could you calculate the before vs after for all of our service gems? I think this will be great to highlight once this gets to prod.

As for the CodeQL failure, will this failure persist after this merge? If so, we should find a way to suppress (if not useful) or find a fix for it.

Comment thread build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/rbs/params.rb Outdated
Copy link
Copy Markdown
Contributor

@jterapin jterapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I would recommend that you run rake sdk:build to see the codegenerated outputs are exactly you expected.

@sichanyoo sichanyoo merged commit 98d97d2 into version-3 May 19, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants